import requests
from lxml import etree
base_url = "https://bbs.itheima.com/forum-425-"
# 循环遍历
for i in range(1,6):
    # 构造url
    url = base_url+str(i)+".html"
    # 请求
    response = requests.get(url)
    # 设置编码格式
    response.encoding = "utf-8"
    # 节点
    node = etree.HTML(response.text)
    # 解析
    titles = node.xpath("//th[@class='new forumtit']/a[@class='s xst']/text()")
    print(titles)